

Oa.controller('mainControl',function($scope,$http){
	$scope.getUserInfo = function(id){
		$http.get(getUserById_url,{
			params:{
				userId:id
			}
		})
		.success(function(res){
			if (res.code==200) {
				$scope.user = res.data;
				var year = parseInt($scope.user.birth.substr(0,4));
				var date = new Date();
				var dateyear = date.getFullYear();
				$scope.user.age = dateyear - year;
				$scope.newuser = $scope.user;
			}
		})
		.error(function(){

		})
	}
	$scope.getUserInfo(sessionStorage.userid);
	$scope.updateUserById = function(){
		$http.post(updateUserById_url,$scope.newuser)
		.success(function(res){
			if (res.code==200) {
				Notify(res.msg,"top-right");
			}else {
				Notify(res.msg,"top-right");
			}
		})
		.error(function(){
			Notify("客户端发送错误，请稍后重试！","top-right");
		})
	}


	$("#askout").on('click', function () {
        bootbox.myforms({
            message: $("#outApplication").html(),
            title: "外出申请",
            className: "modal-darkorange",
            show:true,
            buttons: {
                success: {
                    label: "发送",
                    className: "btn-primary",
                    type:"submit",
                    callback: function (result) {
                    	bootbox.hideAll(),
                    	Notify('发送成功', 'top-right', '5000', 'success', 'fa-check', true)
                    }
                },
            }
        });

    });

	$("#askwork").on('click', function () {
        bootbox.myforms({
            message: $("#workApplication").html(),
            title: "加班单",
            className: "modal-darkorange",
            show:true,
            buttons: {
                success: {
                    label: "发送",
                    className: "btn-primary",
                    type:"submit",
                    callback: function (result) {
                    	bootbox.hideAll(),
                    	Notify('发送成功', 'top-right', '5000', 'success', 'fa-check', true)
                    }
                },
            }
        });

    });

	$("#askleave").on('click', function () {
        bootbox.myforms({
            message: $("#LeaveApplication").html(),
            title: "请假单",
            className: "modal-darkorange",
            show:true,
            buttons: {
                success: {
                    label: "发送",
                    className: "btn-primary",
                    type:"submit",
                    callback: function (result) {
                    	bootbox.hideAll(),
                    	Notify('发送成功', 'top-right', '5000', 'success', 'fa-check', true)
                    }
                },
            }
        });

    });

});
